const { defineConfig } = require("@vue/cli-service");
const { list } = require("./src/mock");
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    setupMiddlewares(middle, { app }) {
      app.get("/api/list", (req, res) => {
        const { pageCode = 1, pageSize = 10 } = req.query
        
        if(pageCode * pageSize <= list.length) {
          res.send({
            code: 200,
            data: list.slice((pageCode - 1) * pageSize, pageCode * pageSize),
            message: `成功请求10条数据`
          })
        } else {
          res.send({
            code: 201,
            data: null,
            message: `没有更多数据了`
          })
        }
      });
      return middle;
    },
  },
});
